import { useUserStore } from '@/store'
const userStore = useUserStore()

export const totalDatasO = {
  paidCommission: 0,
  settleCommission: 0,
  orderNum: 0,
  paidOrderNum: 0,
  cancelOrderNum: 0
}

export const totalDataO = [
  {
    label: `预估${userStore.userInfo.rewardChannelStr}`,
    key: 'paidCommission',
    value: 'todayPaidCommission',
    unit: '元',
    precision: 2
  },
  {
    label: `结算${userStore.userInfo.rewardChannelStr}`,
    key: 'settleCommission',
    value: 'todaySettleCommission',
    unit: '元',
    precision: 2
  },
  {
    label: '订单数',
    key: 'orderNum',
    value: 'todayOrderNum',
    unit: '笔',
    precision: 0
  },
  {
    label: '有效订单',
    key: 'paidOrderNum',
    value: 'todayPaidOrderNum',
    unit: '笔',
    precision: 0
  },
  {
    label: '失效订单',
    key: 'cancelOrderNum',
    value: 'todayCancelOrderNum',
    unit: '笔',
    precision: 0
  }
]

const colorArr = ['#5470C6', '#91CC75', '#FAC858', '#EE6666', '#73C0DE', '#3BA272', '#FC8452', '#9A60B4', '#EA7CCC']

export const graphDataChartOptionBar = {
  legend: {
    show: true,
    itemWidth: 14,
    itemHeight: 14
  },
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'cross',
      crossStyle: {
        color: '#999'
      }
    }
  },
  grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    containLabel: true
  },
  xAxis: {
    type: 'category',
    alignTicks: true,
    axisLine: {
      lineStyle: {
        type: 'solid'
      },
      symbol: ['none'],
      symbolSize: [13, 20],
      symbolOffset: [0, 40]
    },
    data: []
  },
  yAxis: {
    type: 'value'
  },
  series: []
}
export const formatSeries = (seriesItem, line, type) => {
  return {
    data: seriesItem,
    xAxisIndex: line == 'solid' ? 0 : 1,
    color:
      type == 'todayPaidCommission'
        ? colorArr[0]
        : type == 'todaySettleCommission'
        ? colorArr[1]
        : type == 'todayOrderNum'
        ? colorArr[2]
        : type == 'todayPaidOrderNum'
        ? colorArr[3]
        : type == 'todayCancelOrderNum'
        ? colorArr[4]
        : colorArr[5],
    smooth: true,
    itemStyle: {
      normal: {
        lineStyle: {
          width: 2,
          type: line
        }
      }
    },
    type: 'line',
    name:
      type == 'todayPaidCommission'
        ? `预估${userStore.userInfo.rewardChannelStr}`
        : type == 'todaySettleCommission'
        ? `结算${userStore.userInfo.rewardChannelStr}`
        : type == 'todayOrderNum'
        ? '订单数'
        : type == 'todayPaidOrderNum'
        ? '有效订单'
        : type == 'todayCancelOrderNum'
        ? '失效订单'
        : '--'
  }
}
